<html>
<input type="hidden" id="out_trade_no" value="{$out_trade_no}">
</html>
<script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js" type="text/javascript" charset="utf-8"></script>
<script>

    function onBridgeReady(){
        var data={$data};
var out_trade_no=$("#out_trade_no").val();
        WeixinJSBridge.invoke(
            'getBrandWCPayRequest', data,
            function(res){
                console.log(res.err_msg);
                if(res.err_msg == "get_brand_wcpay_request:ok" ) {
                    // 使用以上方式判断前端返回,微信团队郑重提示：res.err_msg将在用户支付成功后返回    ok，但并不保证它绝对可靠。
                    window.location.href="http://mytest.bndvip.com/html/meal_new/pay_success.html?out_trade_no="+out_trade_no;
                }else{
                    window.location.href="http://mytest.bndvip.com/html/meal_new/index.html";
                }
            }
        );
    }


    if (typeof WeixinJSBridge == "undefined"){
        if( document.addEventListener ){
            document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false);
        }else if (document.attachEvent){
            document.attachEvent('WeixinJSBridgeReady', onBridgeReady);
            document.attachEvent('onWeixinJSBridgeReady', onBridgeReady);
        }
    }else{
        onBridgeReady();
    }


</script>